package indi.kane.demandlist.service.impl;

import indi.kane.demandlist.dao.DeveloperMapper;
import indi.kane.demandlist.entity.Developer;
import indi.kane.demandlist.service.IDeveloperService;
import indi.kane.demandlist.vo.ResultVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: DeveloperService
 * @Author: kane
 * @Date: 2020-06-09 12:15 下午
 * @Description:
 */
@Service
public class DeveloperService implements IDeveloperService {
    @Resource
    private DeveloperMapper developerMapper;

    @Override
    public ResultVo selectByMember(Integer member) {
        List<Developer> result = developerMapper.selectByMember(member);
        return ResultVo.success(result);
    }

    @Override
    public ResultVo selectByDemand(Integer demand) {
        List<Developer> result = developerMapper.selectByMember(demand);
        return ResultVo.success(result);
    }

    @Override
    public ResultVo deleteByDemand(Integer demand) {
        int result = developerMapper.deleteByDemand(demand);
        return result > 0? ResultVo.success(result): ResultVo.failed(ResultVo.SUCCESS_CODE_WRONG, "删除数据失败.");
    }

    @Override
    public ResultVo insert(Developer developer) {
        int result = developerMapper.insert(developer.getDemand(),developer.getMember());
        return result > 0? ResultVo.success(result): ResultVo.failed(ResultVo.SUCCESS_CODE_WRONG, "插入数据失败.");
    }

    @Override
    public ResultVo update(Developer developer) {
        int result = developerMapper.update(developer.getId(),developer.getDemand(),developer.getMember());
        return result > 0? ResultVo.success(result): ResultVo.failed(ResultVo.SUCCESS_CODE_WRONG, "更新数据失败.");
    }
}